/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Negocio;

import DATABASE.CarpetasDB;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 *
 * @author Alina
 */
public class ListaCarpetas {
    public static ArrayList<Carpeta> listaCarpetas=new ArrayList();

    public ArrayList<Carpeta> getListaCarpetas() {
        return listaCarpetas;
    }

    public void agregarCarpeta(Carpeta carpeta) throws SQLException {
        CarpetasDB carpetadb = new CarpetasDB();
        this.listaCarpetas.add(carpeta);
        carpetadb.agregarCarpeta(carpeta);
    }
    
    public Carpeta buscarCarpeta(String nombre){
        Carpeta carpeta =new Carpeta();
        for (int i=0; listaCarpetas.size()>i; i++){
            if(listaCarpetas.get(i).getNombre().equals(nombre)){
                carpeta=listaCarpetas.get(i);
                return carpeta;
            }
        }
        return carpeta;
    }
    
    public Carpeta buscarCarpetaId(int id){
        Carpeta carpeta = new Carpeta();
        for (int i=0; listaCarpetas.size()>i; i++){
            
            //System.out.println(listaCarpetas.get(i).getId_caperta());
            if(listaCarpetas.get(i).getId_caperta()==id){
                carpeta=listaCarpetas.get(i);
                //System.out.println(carpeta.getNombre());
                return carpeta;
            }
        }
        //System.out.println("hola");
        return carpeta;
    }
    
    public int getNumCarpetas(){
        return listaCarpetas.size();
    }
    
    public void cargarCarpetas() throws SQLException
    {
        CarpetasDB carpetadb = new CarpetasDB();
        listaCarpetas=carpetadb.listarCarpetas();
    }
}
